package com.yoomiito.app.ui.list

import cn.droidlover.xdroidmvp.net.ApiException
import cn.droidlover.xdroidmvp.net.ApiSubscriber
import cn.droidlover.xdroidmvp.net.XApi
import com.yoomiito.app.base.AppConfig
import com.yoomiito.app.base.BaseActPresenter
import com.yoomiito.app.model.BaseList
import com.yoomiito.app.model.gift.GiftGoods
import com.yoomiito.app.model.home.FeaturedGoodsInfo
import com.yoomiito.app.net.YmApi

class ThemeGoodsSortListPresenter(appConfig: AppConfig) :BaseActPresenter<ThemeGoodsSortListActivity>(appConfig){

    /**
     * 获取商品列表
     */
    fun getList(id: String,page:Int,sort:String) {
        YmApi.getYmService()
                .getFeatureAreaList(id,sort,page)
                .compose(v?.bindToLifecycle())
                .compose(XApi.getApiTransformerData())
                .compose(XApi.getScheduler())
                .subscribe(object : ApiSubscriber<BaseList<GiftGoods>>(handleException()) {
                    override fun onSuccess(t: BaseList<GiftGoods>) {
                        v?.showData(t)
                    }

                    override fun onFail(error: ApiException?) {
                        v.dismissLoading()
                    }
                })
    }
}